package org.test.client.ui.util;

import java.awt.Font;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;

import org.test.client.ui.component.btn.MyUIButton;


/**
 * 组件工厂
 * 暂时未实现完全
 * @author Guodeqi
 *
 */
public class CompFactory {
	
	/**************************Btn start*******************************/
	
	public static MyUIButton createBlueBtn(String starticon,String label,String endIcon){
		MyUIButton btn = new MyUIButton(starticon, label, endIcon);
		btn.setBtnType(MyUIButton.TYPE_BLUE);
		btn.doInit();
		return btn;
	}
	public static MyUIButton createRedBtn(String starticon,String label,String endIcon){
		MyUIButton btn = new MyUIButton(starticon, label, endIcon);
		btn.setBtnType(MyUIButton.TYPE_RED);
		btn.doInit();
		return btn;
	}
	public static MyUIButton createGreenBtn(String starticon,String label,String endIcon){
		MyUIButton btn = new MyUIButton(starticon, label, endIcon);
		btn.setBtnType(MyUIButton.TYPE_GREEN);
		btn.doInit();
		return btn;
	}
	public static MyUIButton createDeepBlueBtn(String starticon,String label,String endIcon){
		MyUIButton btn = new MyUIButton(starticon, label, endIcon);
		btn.setBtnType(MyUIButton.TYPE_DEEP_BLUE);
		btn.doInit();
		return btn;
	}
	public static MyUIButton createOrangeBtn(String starticon,String label,String endIcon){
		MyUIButton btn = new MyUIButton(starticon, label, endIcon);
		btn.setBtnType(MyUIButton.TYPE_ORANGE);
		btn.doInit();
		return btn;
	}
	/**************************Btn end*******************************/
	
	
	
	/**************************field start*******************************/
	
	
	
	
	/**************************field end*******************************/
	
	
	public static JLabel createPicLabel(String path,String info,Font font){
		JLabel label = new JLabel();
		label.setFont(font);
		label.setIcon(Icons.loadIcon(path));
		label.setText(info);
		label.setOpaque(false);
		
		return label;
	}
	
	public static JButton createIconBtn(String txt ,String iconPath,String rolloverIcon,String pressedIcon){
		JButton btn = new JButton(txt);
		
		Icon buttonIcon = new ImageIcon(ClassLoader.getSystemResource(iconPath));
		Icon buttonRoverIcon = new ImageIcon(ClassLoader.getSystemResource(rolloverIcon));
		Icon buttonPressedIcon = new ImageIcon(ClassLoader.getSystemResource(pressedIcon));
		
		btn.setBorder(null);
		btn.setMargin(null);
		btn.setOpaque(false);
		btn.setIcon(buttonIcon);
		btn.setRolloverEnabled(true);
		btn.setRolloverIcon(buttonRoverIcon);
		btn.setPressedIcon(buttonPressedIcon);
		btn.setContentAreaFilled(false);
		btn.setRequestFocusEnabled(false);
		
		return btn;
	}
	
	public static JButton createIconBtn(String iconPath,String rolloverIcon,String pressedIcon){
		return createIconBtn("",iconPath,rolloverIcon,pressedIcon);
	}
	
	
}
